package com.cll.pmis.common;

import com.baomidou.mybatisplus.plugins.Page;

import java.io.Serializable;
import java.util.List;

/**
 * @author chenliangliang
 * @date 2018/7/2
 */
public class PageInfo<T> implements Serializable {

    private static final long serialVersionUID = -5142784235358419988L;

    /**
     * 总记录数
     */
    private long total;
    /**
     * 每页条数
     */
    private int size;
    /**
     * 总页数
     */
    private long pages;
    /**
     * 当前页数
     */
    private int page;
    /**
     * 具体数据
     */
    private List<T> list;

    public PageInfo(Page<T> page) {
        this(page.getCurrent(),page.getSize(),page.getPages(),page.getTotal(),page.getRecords());
    }

    public PageInfo(Integer pageNum,Integer pageSize,Long pages,Long total,List<T> list) {
        this.size = pageSize;
        this.total = total;
        this.pages =pages;
        this.page = pageNum;
        this.list = list;
    }

    public PageInfo(Page page, List<T> list){
        this(page.getCurrent(),page.getSize(),page.getPages(),page.getTotal(),list);
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public long getPages() {
        return pages;
    }

    public void setPages(long pages) {
        this.pages = pages;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public PageInfo() {
    }

    @Override
    public String toString() {
        return "PageInfo{" +
                "total=" + total +
                ", size=" + size +
                ", pages=" + pages +
                ", page=" + page +
                ", list=" + list +
                '}';
    }
}

